﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using nspLable.Function.Systems;
using nspLable.Function;
using Product;
using nspLable.Manage;
using nspJob;
using System.Text;

public partial class job_ResumeShow : System.Web.UI.Page
{
    public string _headstr = "";
    public string _typelike = "";
    public string _footstr = "";
    public string comCount1 = "0";
    public string comCount2 = "0";
    public string comCount3 = "0";
    public int sid = 0;
    public TResume tjb = new TResume();
    public TUser tus = new TUser();
    public string jobtypeStr = "";
    public DataTable typelistTab = new DataTable();
    public string age = "";
    public string readcookies = "";
    public TJob tjb2 = new TJob();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (HttpContext.Current.Request.QueryString["id"] != null && HttpContext.Current.Request.QueryString["id"] != "")
            {
                sid = Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]);
            }
            Bind();
            getFoot();
            getHead();
            readcookies = readcookie();
        }

    }
    private void Bind()
    {
        RResume rjb = new RResume();
        tjb = rjb.GateItem(sid);
        if (tjb == null)
        {
            Response.Redirect(Base.BasePage.Config.WebURL + "job/jobtrade" + Base.BasePage.Config.Rewrite + "?type=2");
        }
        TimeSpan ts = DateTime.Parse(DateTime.Now.ToString()) - DateTime.Parse(tjb.DateofBirth.ToString());
        age = (ts.TotalDays / 365).ToString();
        typelistTab = rjb.GetJobType();
        comCount1 = rjb.GetcompanyCount("").Rows.Count.ToString();
        comCount2 = rjb.GetcompanyCount(" Verify=1 ").Rows.Count.ToString();
        comCount3 = rjb.GetcompanyCount(" (datediff(dd,RegDate,getdate()))=0 ").Rows.Count.ToString();

    }
    public string GetTypeStr(int typeid)
    {
        string str = "";
        RResume rib = new RResume();
        DataTable dt = rib.GetJobType(typeid);
        if (dt.Rows.Count != 0)
        {
            str = Function.GetString(dt.Rows[0]["TypeName"].ToString(), 15);
        }
        return str;
    }
    private void getHead()
    {
        TUserLable Temp = new RUserLable().GateItem("WS_整站头部");
        if (Temp.Info == null || Temp.Info == "")
            _headstr = "";
        else
            _headstr = Temp.Info.ToString();
        _headstr = _headstr.Replace("{PB_WebURL}", Base.BasePage.Config.WebURL);
        _headstr = _headstr.Replace("{PB_收录企业}", comCount1);
        _headstr = _headstr.Replace("{PB_审核通过企业}", comCount2);
        _headstr = _headstr.Replace("{PB_今日收录}", comCount3);
    }
    private void getFoot()
    {
        TUserLable Temp = new RUserLable().GateItem("WS_整站底部");
        if (Temp.Info == null || Temp.Info == "")
            _footstr = "";
        else
            _footstr = Temp.Info.ToString();
        _footstr = _footstr.Replace("{PB_WebURL}", Base.BasePage.Config.WebURL);

    }
    //最新浏览过的招聘信息
    protected string readcookie()
    {
        StringBuilder sb = new StringBuilder();
        if (Base.BasePage.GetCookie("readjob") != null)
        {
            string minolist = Base.BasePage.GetCookie("readjob").ToString();
            if (minolist != "")
            {
                string[] minojob = minolist.Split(',');
                int cnt = 0;
                for (int i = minojob.Length - 1; i >= 0; i--)
                {
                    if (Base.Common.CheckNum(minojob[i].ToString()))
                    {

                        Rjob rjb = new Rjob();
                        tjb2 = rjb.GateItem(int.Parse(minojob[i], 0));
                        if (tjb2 != null)
                        {
                            sb.Append("<li>▪&nbsp;<a title=\"\" target=\"_blank\" href=\"" + Base.BasePage.Config.WebURL + "JobShow-" + int.Parse(minojob[i]) + Base.BasePage.Config.Rewrite + "\">" + Function.GetString(tjb2.Position, 15) + "</a></li>");
                        }
                        if (cnt >= 10) break;
                    }

                }
            }
        }
        return sb.ToString();
    }
}
